<%--
  Created by IntelliJ IDEA.
  User: WuLianFa
  Date: 2018/6/1 0001
  Time: 14:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%
    request.setCharacterEncoding("UTF-8");
    String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title>
    <link href="<%=path%>/CSS/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
    <%@ include file="/WEB-INF/JSP/ajax.jsp" %>
    <script type="text/javascript" src="<%=path%>/HoganJS/handlebars-v4.0.11.js"></script>
    <script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">
    </script>
    <style type="text/css">
        .scbtn2 {
            height: 20px;
            background: #57a0ff;
            border-radius: 20px;
            width: 50px;
            color: #fff;
            display: none;
        }

        .seachform li label {
            line-height: 45px;
            color: #444444
        }

        .scinput {
            line-height: 10px;
            margin-top: 5px
        }

        .scinput1 {
            margin-top: 5px;
            height: 30px;
        }

        .scbtn {
            background: #57a0ff;
            border-radius: 20px;
            width: 110px;
            margin-top: 4px;
            height: 35px
        }

        .scbtn2 {
            height: 20px;
            background: #57a0ff;
            border-radius: 20px;
            width: 50px;
            color: #fff;
            display: none;
        }

        .tablelist {
            border: none;
            margin: 10px 20px
        }

        .tablelist th {
            background: none;
            border-bottom: none;
        }

        thead {
            background: #f2f2f2
        }

        .tablelist th {
            height: 45px;
        }

        .tablelist td {
            border-right: none;
        }

        tbody tr {
            height: 38px
        }

        .check {
            padding-left: 0px
        }

        a {
            cursor: pointer;
        }

        #student td {
            width: 100%;
            padding-left: 30px;
            text-align: center;
        }

        .head th {
            text-align: center;
        }

        #cent td {
            text-align: center;
            padding-left: 5px;
        }

        table tr td {
            font-size: 12px
        }

        table tr th {
            font-size: 14px
        }

        .heads span {
            width: 1573px;
            float: left;
            height: 45px;
            text-align: center;
            line-height: 45px;
            background: #eee;
            font-weight: bold;
            font-size: 14px;
        }

        tbody tr:nth-child(even) {
            background: #f7f8fd
        }

        .tablelist tr td {
            border-bottom: 1px solid #BBB;
        }
    </style>
</head>
<body style="background: #f5f5f5;padding: 0 10px;">
<div class="place" style="background: #f5f5f5;margin-top: 10px">
    <ul class="placeul">
        <li><a href="#">库存管理</a></li>
        <li><a href="#">物品出库</a></li>
    </ul>
</div>

<div class="rightinfo" style="background: #fff;border-radius:10px;height: 45px;">
    <ul class="seachform">
        <ul class="seachform">
            <li><label>物品名称</label><input style="width: 100px" id="goodsName" type="text" class="scinput"/></li>
            <li><label>物品类型</label><input style="width: 100px" id="goodsType" type="text" class="scinput"/>
            </li>
            <li><label>物品规格</label><input style="width: 100px" id="goodsGgid" type="text" class="scinput"/></li>
            <li><label>业务开始时间</label><input style="width: 100px" class="scinput1" name="beginTime" type="text"
                                            onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}',dateFmt:'yyyy-MM-dd'})"
                                            id="datemin" class="input-text Wdate" style="width:150px;"></li>
            <li><label>业务结束时间</label><input style="width: 100px" class="scinput1" name="endTime" type="text"
                                            onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datemin\')}',dateFmt:'yyyy-MM-dd'})"
                                            id="datemax" class="input-text Wdate" style="width:150px;"></li>
            <li><label>&nbsp;</label><input style="width: 100px" name="" type="button" style="outline: none;"
                                            class="scbtn" onclick="goodsAllMassageListPaging()" value="立即查询"/><input
                    type="hidden" name="selectState"
                    value="-1"/></li>
        </ul>
    </ul>
</div>

<div style="width: 100%;overflow:auto;margin-bottom: 0px;margin-top: 30px;background: #fff;border-radius:10px;box-shadow: 0 0 10px #f2f2f2;">
    <ul>
        <li style="height: 40px;text-align: left;color: #999999;">
				  <span style="font-size: 12px;">
				  <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                       src="<%=path%>/images/list/xz.png">
                        &nbsp;<a href="<%=path%>/DrivingSys/jumpToAddOutwarehouseRecord">新增</a>
				  <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                       src="<%=path%>/images/list/sc.png">
                        &nbsp;<a class="del">删除</a>
                        <img alt="" height="11px" src="<%=path%>/images/list/xg.png" style="padding-left: 20px">
                        <a class="modify">修改</a>
                          <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;width: 14px"
                               src="<%=path%>/images/list/excel.png">
                          &nbsp;<a onclick="exportExcel()">导出Excle</a>

				       <label style="padding-left: 50px">&nbsp;</label><input name="" type="submit" class="scbtn2"
                                                                              value="确定"/>
				  </span>
        </li>
    </ul>
    <table class="tablelist" style="width: 100%;white-space:nowrap;">
        <thead>
        <tr class="sq">
            <th align="center"><input type="checkbox" class="check1"/></th>
            <th align="center">出库编号</th>
            <th align="center">出库用途</th>
            <th align="center">出库接收方</th>
            <th align="center">审核人</th>
            <th align="center">审核状态</th>
            <th align="center">创建人</th>
            <th align="center">创建时间</th>
            <th align="center">最后修改人</th>
            <th align="center">最后修改时间</th>
            <th align="center">驾校</th>
            <th align="center">物品名称</th>
            <th align="center">物品类型</th>
            <th align="center">物品规格</th>
            <th align="center">物品单价</th>
            <th align="center">物品出库单价</th>
            <th align="center">出库物品数量</th>
            <th align="center">出库物品总价</th>
            <th align="center">操作</th>
        </tr>
        </thead>

        <tbody class="allOutwarehouseMassageOptionAppendTo">
        <%-- ajax响应内容区--%>
        </tbody>

    </table>
</div>

当前第<a class="currentPage"></a>页&nbsp;
共<a class="trailerPage"></a>页&nbsp;
每页显示<input style="width: 50px;border:0.5px solid #378888" class="pageSize" type="text" placeholder="输入条数"
           onkeydown="EnterPress()"/>条数据&nbsp;
<a href="javascript:void(0)" onclick="fristPage()">[首页]</a>
<a href="javascript:void(0)" onclick="prePage()">上一页</a>
<a href="javascript:void(0)" onclick="nextPage()">下一页</a>
<a href="javascript:void(0)" onclick="endPage()">[尾页]</a>

<div class="tip">
    <div class="tiptop">
        <span>提示信息</span>
    </div>
    <div class="tipinfo">
        <span><img src="<%=path%>/images/ticon.png"/></span>
        <div class="tipright">
            <p>是否确认对信息删除 ？</p>
            <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
        </div>
    </div>
    <div class="tipbtn">
        <input name="" type="button" class="sure" value="确定"/>&nbsp; <input
            name="" type="button" class="cancel" value="取消"/>
    </div>
</div>

</body>
<script type="text/javascript">
    $(document).ready(function () {
        goodsAllMassageListPaging(99999999, 99999999);
    })

    /*====================================分页========================================*/
    var trailerPage = 1;//尾页
    var currentPage = 1;
    var pageSize;

    //首页
    function fristPage() {
        currentPage = 1;
        goodsAllMassageListPaging();
    }

    //上一页
    function prePage() {
        currentPage--;
        if (currentPage <= 0) {
            currentPage = 1;
        }
        goodsAllMassageListPaging();
    }

    //下一页
    function nextPage() {
        var tPage = $(".trailerPage").html();
        if (parseInt(tPage) != 0) {
            if (currentPage == trailerPage) {
                currentPage = trailerPage;
            } else {
                currentPage++;
            }
            goodsAllMassageListPaging();
        }
    }

    //尾页
    function endPage() {
        var tPage = $(".trailerPage").html();
        if (parseInt(tPage) != 0) {
            currentPage = trailerPage;
            goodsAllMassageListPaging();
        }
    }

    //输入显示每页数回车刷新数据
    function EnterPress() {
        if (event.keyCode == 13) {
            goodsAllMassageListPaging();
        }
        currentPage = 1;
    }

    //分页
    function goodsAllMassageListPaging(x, y) {
        var goodsName = $("#goodsName").val();//要搜索的物品名称
        var goodsType = $("#goodsType").val();//要搜索的物品名称
        var goodsGgid = $("#goodsGgid").val();//要搜索的物品名称
        var beginTime = $("#datemin").val();
        var endTime = $("#datemax").val();
        var pageSizeInput = $(".pageSize").val();//输入的每页显示条数
        if (pageSizeInput != null && pageSizeInput != '') {
            pageSize = parseInt(pageSizeInput);
        } else {
            pageSize = 3;
        }
        $.ajax({
            url: '<%=path%>/DrivingSys/OutwarehouseMassagePaging', //请求的url
            type: 'post', //请求的方式
            data: {
                "currentPage": currentPage,
                "pageSize": pageSize,
                "goodsName": goodsName,
                "goodsType": goodsType,
                "goodsGgid": goodsGgid,
                "beginTime": beginTime,
                "endTime": endTime
            },
            success: function (data) {
                trailerPage = data.getLastPage;
                if (data.outwarehousetables == null || data.outwarehousetables == '') {
                    $(".allOutwarehouseMassageOptionAppendToRemove").remove();
                    var str = "<tr class='allOutwarehouseMassageOptionAppendToRemove'><th colspan='13'><span>抱歉,没有任何相关的记录信息!</span></th> </tr>";
                    $(".allOutwarehouseMassageOptionAppendTo").append(str);
                } else {
                    $(".allOutwarehouseMassageOptionAppendToRemove").remove();
                    for (var i = 0; i < data.outwarehousetables.length; i++) {
                        debugger;
                        var childrenLength = data.outwarehousetables[i].outwarehousechildren.length;
                        var childrenLength1;
                        var childrenLength2;
                        if (i == x) {
                            if (y == 0) {//合并
                                childrenLength1 = 6;
                                childrenLength2 = childrenLength1-1;
                            } else if (y == 1) {//展开
                                childrenLength1 = childrenLength+1;
                                childrenLength2 = childrenLength1-1;
                            }
                        } else {
                            if (childrenLength > 5) {
                                childrenLength1 = 6;
                                childrenLength2 = childrenLength1-1;
                            }else {
                                childrenLength1 = childrenLength;
                                childrenLength2 = childrenLength;
                            }
                        }
                        var str = "<tr class='allOutwarehouseMassageOptionAppendToRemove' ondblclick='doubleClickTheQuery(\"" + data.outwarehousetables[i].ckId + "\")'>" +
                            "<td rowspan='" + childrenLength1 + "'><input type='checkbox' name='outwarehouseMassageCheckboxName' value='" + data.outwarehousetables[i].ckId + "'/></td>" +
                            "<td rowspan='" + childrenLength1 + "'>" + data.outwarehousetables[i].ckId + "</td>" +
                            "<td rowspan='" + childrenLength1 + "'>" + data.outwarehousetables[i].ckOutwarehouseuse + "</td>" +
                            "<td rowspan='" + childrenLength1 + "'>" + data.outwarehousetables[i].ckOutwarehouseaccepter + "</td>" +
                            "<td rowspan='" + childrenLength1 + "'>" + data.outwarehousetables[i].ckAuditor + "</td>" +
                            "<td rowspan='" + childrenLength1 + "'>" + data.outwarehousetables[i].ckAuditstatus + "</td>" +
                            "<td rowspan='" + childrenLength1 + "'>" + data.outwarehousetables[i].ckCreator + "</td>" +
                            "<td rowspan='" + childrenLength1 + "'>" + data.outwarehousetables[i].ckCreationtime + "</td>" +
                            "<td rowspan='" + childrenLength1 + "'>" + data.outwarehousetables[i].ckLastmodifier + "</td>" +
                            "<td rowspan='" + childrenLength1 + "'>" + data.outwarehousetables[i].ckLastmodificationtime + "</td>" +
                            "<td rowspan='" + childrenLength1 + "'>" + data.outwarehousetables[i].ckSchoolid + "</td>" +
                            "<td>" + data.outwarehousetables[i].outwarehousechildren[0].ckOutwarehousegoodsname + "</td>" +
                            "<td>" + data.outwarehousetables[i].outwarehousechildren[0].ckOutwarehousegoodstype + "</td>" +
                            "<td>" + data.outwarehousetables[i].outwarehousechildren[0].ckOutwarehouseggid + "</td>" +
                            "<td>" + data.outwarehousetables[i].outwarehousechildren[0].ckOutwarehousegoodsprice + "</td>" +
                            "<td>" + data.outwarehousetables[i].outwarehousechildren[0].ckOutwarehouseprice + "</td>" +
                            "<td>" + data.outwarehousetables[i].outwarehousechildren[0].ckOutwarehousequantity + "</td>" +
                            "<td>" + data.outwarehousetables[i].outwarehousechildren[0].ckOutwarehousetotalprices + "</td>" +
                            "<td rowspan='" + childrenLength1 + "'>" +
                            "<img alt='' height='11px' src='<%=path%>/images/list/xg.png'>" +
                            "<a href='<%=path%>/DrivingSys/queryOutwarehouseMassageByckId?ckId=" + data.outwarehousetables[i].ckId + "'class='tablelink'>修改</a>&nbsp;&nbsp;&nbsp;" +
                            "<img alt='' style='margin-top: 20px;margin-left: 22px;height: 12px;'src='<%=path%>/images/list/sc.png'>&nbsp;" +
                            "<a class='delOne' class='tablelink' style='color: #056dae' onclick='removingAsingle(\"" + data.outwarehousetables[i].ckId + "\")'>删除</a>&nbsp;&nbsp;&nbsp;" +
                            "</td></tr>";
                        //循环子表
                        for (var j = 1; j < childrenLength2; j++) {
                            str +=
                                "<tr ondblclick='doubleClickTheQuery(\"" + data.outwarehousetables[i].ckId + "\")' class='allOutwarehouseMassageOptionAppendToRemove'><td>" + data.outwarehousetables[i].outwarehousechildren[j].ckOutwarehousegoodsname + "</td>" +
                                "<td>" + data.outwarehousetables[i].outwarehousechildren[j].ckOutwarehousegoodstype + "</td>" +
                                "<td>" + data.outwarehousetables[i].outwarehousechildren[j].ckOutwarehouseggid + "</td>" +
                                "<td>" + data.outwarehousetables[i].outwarehousechildren[j].ckOutwarehousegoodsprice + "</td>" +
                                "<td>" + data.outwarehousetables[i].outwarehousechildren[j].ckOutwarehouseprice + "</td>" +
                                "<td>" + data.outwarehousetables[i].outwarehousechildren[j].ckOutwarehousequantity + "</td>" +
                                "<td>" + data.outwarehousetables[i].outwarehousechildren[j].ckOutwarehousetotalprices + "</td></tr>";
                        }
                        if (childrenLength > 5) {
                            str += "<tr class='allOutwarehouseMassageOptionAppendToRemove'>" +
                                "<td><a id='viewDetails" + i + "' onclick='viewDetails(" + i + ")'>查看详情</a>&nbsp;&nbsp;&nbsp;<a id='packUpTheDetails" + i + "' onclick='packUpTheDetails(" + i + ")'>收起详情</a></td>" +
                                "<td></td>" +
                                "<td></td>" +
                                "<td></td>" +
                                "<td></td>" +
                                "<td></td>" +
                                "<td></td></tr>";
                        }
                        $(".allOutwarehouseMassageOptionAppendTo").append(str);
                    }
                    $(".trailerPage").html(trailerPage);//总页数赋值
                    $(".currentPage").html(currentPage);//当前页赋值
                }
            }
        })
    }

    //查看详情
    function viewDetails(i) {
        goodsAllMassageListPaging(i, 1);
    }

    //收起详情
    function packUpTheDetails(i) {
        goodsAllMassageListPaging(i, 0);
    }

    /*====================================分页========================================*/

    //删除多个
    $('.del').click(function () {
        var findid = document.getElementsByName("outwarehouseMassageCheckboxName");
        var ckId;
        for (var i = 0; i < findid.length; i++) {
            if (findid[i].checked) {
                ckId = findid[i].value;
            }
        }
        if (ckId == null || ckId == "") {
            alert("请至少选择一条数据删除！")
            return false
        } else {
            $(".tip").fadeIn(200);
            $("#tip2").css('visibility', 'visible');
        }
        $(".sure").click(function () {
            $(".tip").fadeOut(100);
            var str = new Array();
            for (var i = 0; i < findid.length; i++) {
                if (findid[i].checked) {
                    str[i] = findid[i].value;
                }
            }
            location = '<%=path%>/DrivingSys/deleteOutwarehouseMassage?ckIdArray=' + str;
        })

        $(".cancel").click(function () {
            $(".tip").fadeOut(100);
            $("#tip2").css('visibility', 'hidden');
        });
    })

    //删除单个
    function removingAsingle(ckId) {
        $("#tip2").css('visibility', 'visible');
        $(".tip").fadeIn(200);
        $(".sure").click(function () {
            location = '<%=path%>/DrivingSys/deleteOutwarehouseMassage?ckId=' + ckId;
        })

        $(".cancel").click(function () {
            $(".tip").fadeOut(100);
            $("#tip2").css('visibility', 'hidden');
        });
    }

    //修改
    $(".modify").click(function () {
        var stringFid;
        var fids = document.getElementsByName("outwarehouseMassageCheckboxName");
        for (var i = 0; i < fids.length; i++) {
            if (fids[i].checked) {
                stringFid = fids[i].value;
                location = '<%=path%>/DrivingSys/queryOutwarehouseMassageByckId?ckId=' + stringFid;
                return false
            }
        }
        if (stringFid == null || stringFid.length == 0) {
            alert("请至少选择一条数据修改")
            return false
        }
    })


    //查询详情
    function doubleClickTheQuery(ckId) {
        location = '<%=path%>/DrivingSys/queryOutwarehouseMassageByckId?ckId=' + ckId;
    }

    //全选全不选
    $(".check1").click(function () {
        if (this.checked) {
            $("[name=outwarehouseMassageCheckboxName]").attr("checked", true);
        }
        else {
            $("[name=outwarehouseMassageCheckboxName]").attr("checked", false);
        }
    })

    //导出
    function exportExcel() {
        var findid = document.getElementsByName("outwarehouseMassageCheckboxName");
        var ckIdArray = new Array();
        var j = 0;
        for (var i = 0; i < findid.length; i++) {
            if (findid[i].checked) {
                ckIdArray[j] = findid[i].value;
                j++;
            }
        }
        location = '<%=path%>/DrivingSys/exportOutwarehouseMassageExcel?ckIdArray=' + ckIdArray;
    }

</script>
</html>
